<?php

require_once dirname(__FILE__).'/../lib/representation_spectacleGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/representation_spectacleGeneratorHelper.class.php';

/**
 * representation_spectacle actions.
 *
 * @package    tfe
 * @subpackage representation_spectacle
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class representation_spectacleActions extends autoRepresentation_spectacleActions
{
      protected function processForm(sfWebRequest $request, sfForm $form)
      {
        $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));

        if ($form->isValid())
        {
          $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';

          $representation_spectacle = $form->save();

          $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $representation_spectacle)));

          if ($request->hasParameter('_save_and_add'))
          {
            $this->getUser()->setFlash('notice', $notice.' You can add another one below.');

            $this->redirect('@representation_spectacle_new');
          }
          else
          {
            $this->getUser()->setFlash('notice', $notice);

            $this->redirect(array('sf_route' => 'representation_spectacle_edit', 'sf_subject' => $representation_spectacle));
          }
        }
        else
        {
          $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
        }
      }
}
